<?php

namespace app\api\behavior;

use think\Request;
use think\Response;

class CORS
{
    public function appInit(&$params)
    {
        $origin = Request::instance()->header('Origin');
        header('Access-Control-Allow-Origin:' . $origin);
        header("Access-Control-Allow-Headers: token,Origin, X-Requested-With, Content-Type, Accept");
        header('Access-Control-Allow-Methods: POST,GET,PATCH');
        header("Access-Control-Allow-Credentials: true");
        if (request()->isOptions()) {
            exit();
        }
    }
}
